﻿using UnityEngine;
using System.Collections;

public class CameraTrigger: MonoBehaviour {

	public Camera playerCamera;
	public float camHeight = 6f;
	public float camSpeed = 5f;
	public bool active = false;

	void Update(){
		if(active){
			Vector3 nextPos = new Vector3(transform.position.x,camHeight,transform.position.z);
			playerCamera.transform.position = Vector3.MoveTowards(playerCamera.transform.position,nextPos,Time.deltaTime*camSpeed);
		}

	}

	void OnTriggerEnter(Collider collider){
		if(collider.tag == "Player"){
			active = true;
		}
	}

	void OnTriggerExit(Collider collider){
		if(collider.tag == "Player"){
			active = false;
		}
	}
}
